package com.java.crazy.part17.net;

import com.java.crazy.base.BaseClass;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class MyServer extends BaseClass {
    public static List<Socket> socketList = Collections.synchronizedList(new ArrayList<>());

    public static void main(String[] args) throws IOException {

        ServerSocket serverSocket = new ServerSocket(30001);
        while (true) {
            logi("1111");
            Socket socket = serverSocket.accept();
            socketList.add(socket);
            new Thread(new ServerThread(socket)).start();
//            PrintStream printStream = new PrintStream(socket.getOutputStream());
//            printStream.print("你好，我是服务器！" + socket.getSendBufferSize());
//            printStream.close();
//            socket.close();
        }
    }
}
